<?php 
/*
Plugin Name: Seta recruit
*/
class Seta_recruit_Widget extends WP_Widget{

  public function __construct() {
        parent::__construct(false,$name = __('Seta Recruit'));
  }
  public function widget( $args,$instanse ){

    if(isset($instanse['show_post_widget_title'])){
        $widget_title = $instanse['show_post_widget_title'];
    }

    if(isset($instanse['show_post_widget_cat_value'])){
        $cat_id = $instanse['show_post_widget_cat_value'];
    }

    if(isset($instanse['num_post'])){
        $num_post = $instanse['num_post'];
    }
?>
<!-- output html -->
<div id="recruitment" class="region text-center bg-highlighted animated-area">
  <div class="container">
    <h2 class="title-big">Vị trí tuyển dụng</h2>
    <?php
      $args = array('posts_per_page' => $num_post,'cat' => $cat_id);
      query_posts($args);
      while(have_posts()) : the_post();
    ?>
      <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">BrSE_Kĩ sư cầu nối/PM tiếng nhật <span>2 vị trí</span></a>
    <?php
      endwhile;
    ?>
    <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">BrSE_Kĩ sư cầu nối/PM tiếng nhật <span>2 vị trí</span></a>
    <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">QA/Tester cho thị trường Mĩ <span>3 vị trí</span></a>
    <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">iOS/OSX/ Android Developer <span>2 vị trí</span></a>
    <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">PHP Developer <span>5 vị trí</span></a>
    <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">Perl Developer <span>4 vị trí</span></a>
    <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">.Net Developer <span>3 vị trí</span></a>
    <a href="javascript:void(0)" class="btn animated" data-animation="fadeInDown" role="button">ColdFusion Developer <span>1 vị trí</span></a>
  </div>
</div>
<?php 
  }
  public function form( $instanse ){

    $instance = wp_parse_args( (array) $instance, $defaults );

    if(isset($instanse['show_post_widget_cat_value'])){
        $show_post_widget_cat_value = $instanse['show_post_widget_cat_value'];
    }
    
    if(isset($instanse['show_post_widget_title'])){
        $show_post_widget_title = $instanse['show_post_widget_title'];
    }
    
    if(isset($instanse['num_post'])){
        $num_post = $instanse['num_post'];
    }
?>
<!-- Widget form -->
<p>Title:<input type="text" name="<?php echo $this->get_field_name('show_post_widget_title'); ?>" value="<?php echo $show_post_widget_title; ?> " /></p>
<?php    
  }
  public function update($new_instance,$old_instance){
    $instance = $old_instance;
      
    $instance['show_post_widget_cat_value'] = (!empty($new_instance['show_post_widget_cat_value'])) ? 
    strip_tags($new_instance['show_post_widget_cat_value']) : '';
    
    $instance['show_post_widget_title'] = (!empty($new_instance['show_post_widget_title'])) ? 
    strip_tags($new_instance['show_post_widget_title']) : '';
    
    $instance['num_post'] = (!empty($new_instance['num_post'])) ? 
    strip_tags($new_instance['num_post']) : '';
    
    return $instance;
  }
}
add_action('widgets_init',function(){register_widget('Seta_recruit_Widget');});